fix: Avoid locale-dependent NumberFormat in IntegerSchema#5140
Merged
ewaostrowska merged 1 commit intoJun 18, 2026
Merged
Conversation
|
|
||
| import static org.testng.Assert.*; | ||
|
|
||
| public class IntegerSchemaTest { |
Contributor
Author
There was a problem hiding this comment.
If it is of interest I could add the tests first in a PR to showcase the current behavior, and then do a PR afterwards that changes the implementation (but also showcases that the behavior is the same).
Contributor
There was a problem hiding this comment.
I think the current test coverage is sufficient
695c5cd to
bfdb5e9
Compare
bfdb5e9 to
428e283
Compare
Co-authored-by: jhannes <jhannes@users.noreply.github.com>
428e283 to
1d143d8
Compare
Contributor
|
Thank you for reviewing this comment @Mattias-Sehlstedt :) |
ewaostrowska
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Thank you for contributing to swagger-core!
Please fill out the following information to help us review your PR efficiently.
Description
This is a revival of #4178.
NumberFormat.getInstance().parse(Integer.toString(-1)) always throws exception in the following locales: ar· ·ckb· ·he· ·ks· ·pa_Arab· ·ur· ·fa· ·ps· ·uz_Arab· ·eo· ·et· ·fi· ·fo· ·gsw· ·ksh· ·lt· ·nb· ·nn· ·rm· ·se· ·sv· (see https://bugs.openjdk.java.net/browse/JDK-8189097)
To see this in action, try running the following code:
It should be valid to ignore locale for
IntegerSchema, since we are not conducting any parsing based upon the locale (since we are doingInteger.parseInt()andLong.parseLong(), without considering theNumber castedthat we instantiate).The locale is mainly used for different decimal representations and thousand separators, but these already fail silently in the current implementation. This since the
Number castedis properly read and populated. E.g.,2 000to2000, but we then do Integer.parseInt() with2 000, which will fail.Fixes: #4223
Type of Change
Checklist
Screenshots / Additional Context